<?php

namespace app\admin\model\oil;

use think\Model;


class Fuel extends Model
{

    // 表名
    protected $name = 'oil_fuel';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = false;

    // 追加属性
    protected $append = [
        'guns_array',
    ];

    public function getGunsArrayAttr($value, $data)
    {
        $numbers = explode(",", $data['guns']);
        $output = [];
        foreach ($numbers as $number) {
            $output[] = ['key' => $number, 'title' => $number . '号枪'];
        }
        return $output;
    }
    public function store () {
        return $this->belongsTo(\app\admin\model\oil\Store::class, 'store_id');
    }







}
